package com.sdlogan.pbudget;

import org.achartengine.ChartFactory;
import org.achartengine.chart.PointStyle;
import org.achartengine.model.TimeSeries;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;

public class LineGraph {
	public Intent getIntent(Context ctx) {
		int[] x = {1,2,3,4,5,6,7,8,9,10};
		int[] y = {30,89,34,41,65,45,56,252,625,425};
		
		TimeSeries series = new TimeSeries("Line1");
		for (int i = 0; i < x.length; i++) {
			series.add(x[i], y[i]);
		}
		
		XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
		dataset.addSeries(series);
		
		XYMultipleSeriesRenderer mxs = new XYMultipleSeriesRenderer();
		XYSeriesRenderer xs = new XYSeriesRenderer();
		mxs.addSeriesRenderer(xs);
		
		Intent intent = ChartFactory.getLineChartIntent(ctx, dataset, mxs,"Chart Title");
		
		return intent;
	}
	
	public View getView(Context ctx) {
		int[] x = {1,2,3,4,5,6,7,8,9,10};
		int[] y = {30,89,34,41,65,45,56,252,625,425};
		
		TimeSeries series = new TimeSeries("Line1");
		for (int i = 0; i < x.length; i++) {
			series.add(x[i], y[i]);
		}
		
		XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
		dataset.addSeries(series);
		
		XYMultipleSeriesRenderer mxs = new XYMultipleSeriesRenderer();
		XYSeriesRenderer xs = new XYSeriesRenderer();
		xs.setColor(Color.WHITE);
		xs.setPointStyle(PointStyle.TRIANGLE);
		xs.setFillPoints(true);
		mxs.addSeriesRenderer(xs);
		mxs.setChartTitle("Values");
		
		View v = ChartFactory.getLineChartView(ctx, dataset, mxs);
		return v;	
	}

}
